package rlb;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import rlb.test.RobotTestBed;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;

/**
 * Test Avoidance Techniques.
 * @author Remy Baumgarten
 *
 */
public class TestFlankBotSurvival extends RobotTestBed {
  
  @Override
  public String getRobotNames() {
    return "sample.Walls,rlb.FlankBot";
  }

  /**
   * This test runs for 10 rounds.
   * 
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * The actual test, which asserts that FlankBot has a good survival score.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {

    // Return the results in order of getRobotNames.
    BattleResults[] results = event.getIndexedResults();
    int survival = results[1].getSurvival();
    System.out.println("FlankBots Survival Score " + survival);
    // Sanity check that results[1] is FlankBot (not strictly necessary, but illustrative).
    assertEquals("Check results[1]", results[1].getTeamLeaderName(), "rlb.FlankBot");

    // Check to see if FlankBot can Hit Walls a few times
    assertTrue("Checking if Survival techniques are ok", (survival > 100));
  }
}